﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using yiCommerce.Service.Pictures;

namespace yiCommerce.Controllers.api
{

    public class GetPicUrlRequest
    {
        public int PicId { get; set; }
        public int PicSize { get; set; }
    }

    public class GetPicUrlResult
    {
        public string PicUrl { get; set; }
    }

    public class PicApiController : ApiController
    {
        private IPictureService _pictureService;

        public PicApiController(IPictureService pictureService)
        {
            _pictureService = pictureService;
        }

        [HttpPost]
        public GetPicUrlResult GetPicUrl(GetPicUrlRequest request)
        {
            var result = new GetPicUrlResult();

            var url = _pictureService.GetPictureUrl(request.PicId, request.PicSize, true);

            result.PicUrl = url;

            return result;
        }
    }
}
